package com.etime.shuhuiyuan.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.etime.shuhuiyuan.pojo.CourseChapter;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
 * CourseChapter示例的dao数据逻辑层
 * 需要继承mybatis plus的basemapper接口
 */
@Repository
public interface CourseChapterDao extends BaseMapper<CourseChapter> {

    //查询章
    @Select("select * from chapter where chapterpid = -1")
    Page<CourseChapter> selectChapterListByPage(Page<CourseChapter> page,CourseChapter courseChapter);

    //查询节
    @Select("select * from chapter where chapterpid = #{chapterpid}")
    Page<CourseChapter> selectKnotListByPage(Page<CourseChapter> page,CourseChapter courseChapter,@Param("chapterpid") Integer chapterpid);

    //根据课程id查询章
    @Select("select * from chapter where courseid = #{courseid} and chapterpid = -1")
    List<CourseChapter> selectChapterByCourseId(CourseChapter courseChapter,@Param("courseid") Integer courseid);

}
